package com.tmt.paymentcenter.web.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import tmt.usercenter.web.domain.TmtUser;
import tmt.usercenter.web.domain.UserInfo;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 交易用户
 */
@Getter
@Setter
@Entity
@EntityListeners({AuditingEntityListener.class})
public class TradeUser extends UserInfo implements Serializable {

    @Column(nullable = false)
    private long tmtUserId;

    /**
     * 绑定的商户, 可为NULL
     */
    @OneToOne
    @JoinColumn(name="tradeCompany_id")
    private TradeCompany bindingCompany;

    /**
     * 用户所有的账户
     */
    @OneToMany(mappedBy = "tradeUser", cascade = {CascadeType.REFRESH})
    private List<Account> accounts;

    /**
     * 作为支付人关联的所有交易记录
     */
    @OneToMany(mappedBy = "outUser", cascade = {CascadeType.REFRESH})
    private List<TradeDetailHistory> outTradeDetailHistories;

    /**
     * 作为收钱人关联的所有交易记录
     */
    @OneToMany(mappedBy = "inUser", cascade = {CascadeType.REFRESH})
    private List<TradeDetailHistory> inTradeDetailHistories;

}
